package cn.itcast.day04.demo03;

import java.util.Random;
import java.util.Scanner;

public class Demo04RandomGame {
    public static void main(String[] args) {
        Random r = new Random();
        int num = r.nextInt(100) + 1;
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入你猜测的数字:");
            int guessNum = sc.nextInt();
            if (guessNum > num) {
                System.out.println("猜测的数字太大，请重试！");
            } else if (guessNum < num) {
                System.out.println("猜测的数字太小，请重试！");
            } else {
                System.out.println("恭喜您你猜中了！");
                break;
            }
        }
        System.out.println("游戏结束！随机数为:"+num);
    }
}
